using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TableGuideStepDao:DaoBase<TableGuideStep>
    {
        public override void AddPrimaryIndex(TableGuideStep model)
        {
            cachePrimary[model.stepId.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TableGuideStep.txt";
        }

        protected override TableGuideStep ParseRowData(string[] rowData)
        {
            TableGuideStep data = new TableGuideStep();
			data.stepId = rowData [0];
			data.guideId = rowData [1];
			data.type = rowData [2];
			data.tag = rowData [3];
			data.path = rowData [4];
			data.text = rowData [5];
			data.param = rowData [6];

            if (string.IsNullOrEmpty(rowData[7]))
            {
                data.hand = 0;
            }
            else
            {
                data.hand = int.Parse(rowData[7]);
            }

            if (string.IsNullOrEmpty(rowData[8]))
            {
                data.dialogType = 0;
            }
            else
            {
                data.dialogType = int.Parse(rowData[8]);
            }

            if (string.IsNullOrEmpty(rowData[9]))
            {
                data.posX = 0;
            }
            else
            {
                data.posX = double.Parse(rowData[9]);
            }

            if (string.IsNullOrEmpty(rowData[10]))
            {
                data.posY = 0;
            }
            else
            {
                data.posY = double.Parse(rowData[10]);
            }

            return data;
        }


        public override void AddOneIndex(TableGuideStep model)
        {
            if (!cacheOneIndex.ContainsKey(model.guideId.ToString()))
            {
                cacheOneIndex[model.guideId.ToString()] = new List<TableGuideStep>();
            }
            cacheOneIndex[model.guideId.ToString()].Add(model);
        }
    

    }

}
